cmake_minimum_required(VERSION 2.7)
project(readline)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
file(GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)
file(GLOB hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
add_definitions(-DHAVE_CONFIG_H)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H)
configure_file(config.h.cmake.in config.h)
if(BUILD_DLL)
  add_library(${PROJECT_NAME} SHARED ${srcs} ${hdrs})
else()
  add_library(${PROJECT_NAME} STATIC ${srcs} ${hdrs})
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
install(FILES ${hdrs} DESTINATION include/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)